#include <iostream>
#include <cstdio>
#include <cstring>

#define MAXN 10010

using namespace std;

int x[MAXN], y[MAXN], dx[MAXN], dy[MAXN];

inline int read(){
int x=0,f=1;
char ch=getchar();
while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9') {x=x*10+ch-48;ch=getchar();}
return x*f;
}

int main(){
    int n;
    int xx,yy;
    int ans = -1;
    cin >> n;
    for(int i = 1; i <= n; i++){
        x[i] = read();  y[i] = read();  dx[i] = read();  dy[i] = read();
    }
    xx = read();     yy = read();
    for(int i = 1; i <= n; i++) {
        if(xx >= x[i] && yy >= y[i] && xx <= x[i] + dx[i] && yy <= y[i] + dy[i]) {
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}